<!-- 该组件为推荐菜单组件 -->
<template>
  <div class="home-recommond">
    <h2>主播新人榜</h2>
    <div class="wrapper" ref="wrapper">
      <ul class="content" ref="content">
        <li
          v-for="(item, index) in listData"
          :key="index"
          @click="selectItem(item)"
        >
          <div class="cover">
            <van-image :src="item.avatarUrl" radius="1rem" />
            <!-- <span>{{ item.listen_num | numFilter(1) }}万</span> -->
          </div>
          <span>{{ item.nickName }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { betterScrollHorizontal } from "../../common/betterScroll.js";
export default {
  data() {
    return {
      listData: [],
    };
  },
  created() {
    this.getListData();
  },

  methods: {
    getListData() {
      this.$request("get", "/dj/toplist/newcomer?limit=12").then((res) => {
        console.log(res.data.list);
        this.listData = res.data.list;
        if (res.data.list == 3) {
          this.listData = res.data.list;
        }
        
        betterScrollHorizontal(
          this,
          this.$refs.wrapper,
          this.$refs.content,
          this.listData.lenght,
          10
        );
      });
    },

    // selectItem(item) {
    //   const id = item.content_id; 
    //   this.$router.push({ path: `/singlist/${id}` });
    // },
  },
  // filters: {
  //   /**
  //    *@param {*} value 为需要处理的数字
  //    *@param {*} num 为
  //    */
  //   numFilter(value, num) {
  //     return parseFloat(value / 10000).toFixed(num);
  //   },
  // },
};
</script>
<style scoped>
.cover > span {
  position: absolute;
  right: 0;
  bottom: 0.3rem;
  color: white;
  font-size: 14px;
  border-radius: 1rem;
  display: inline-block;
  background: rgba(0, 0, 0, 0.4);
}
.cover {
  position: relative;
}
.wrapper {
  width: 100%;
  overflow: hidden;
}
ul.content {
  width: calc(6 * 10rem);
}
ul.content li {
  display: inline-block;
  width: 10rem;
  vertical-align: top;
}
ul.content li * {
  margin: 0.1rem;
}
ul.content li > span {
  font-size: 0.8rem;
  color: #54493b;
}
</style>